﻿Imports FixSoft.Fixed.Forms
Imports System.Runtime.InteropServices

''' <summary>
''' A Form that it is transparent and has no border.Use for Two Floor Rendering Technology.
''' </summary>
''' <remarks>This Form works with TransparentyKey trick.
''' It sets BackColor and TransparentyKey to MaskColor,so Form like transparent.</remarks>
Public Class ForeForm

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim p As CreateParams = MyBase.CreateParams
            ' Return p
            ' p.Style =  CInt(AeroAPIs.WS_CHILD)
            'p.Style = p.Style Or CInt(AeroAPIs.WS_CLIPSIBLINGS)
            p.ExStyle = p.ExStyle And CInt(AeroAPIs.WS_EX_LAYERED)
            'p.Parent = AeroAPIs.GetDesktopWindow()
            Return p
        End Get
    End Property
    ' Note: If MaskColor be DarkGray ,it works well but if MaskColor be Blue,it doesn't work correctly. 
    Dim MaskColorv As Color = Color.DarkGray       'Color.FromArgb(255, 200, 200, 200) ' Color.DarkGray     'SystemColors.ActiveCaption 'Color.Fuchsia
    ''' <summary>
    ''' Gets or sets color of transparenty mask.
    ''' </summary>
    ''' <remarks>This Form works with TransparentyKey trick.
    ''' It sets BackColor and TransparentyKey to MaskColor,so Form like transparent.</remarks>
    Public Property MaskColor As Color
        Get
            Return MaskColorv
        End Get
        Set(ByVal value As Color)
            MaskColorv = value
            UpdateMask()
        End Set
    End Property
    ''' <summary>
    ''' Update transparenty mask of Form.
    ''' </summary>
    Public Sub UpdateMask()
        Me.BackColor = MaskColor
        Me.TransparencyKey = Me.BackColor
    End Sub
    Private Sub SystemButtonsInAero_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        UpdateMask()
        Me.ShowInTaskbar = True
    End Sub

    Private Sub SystemButtonsInAero_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        DrawAeroText(e.Graphics, Label5.Location, Label5.Text, Label5.Font, New SolidBrush(Label5.ForeColor))
    End Sub
End Class